package org.JWCB.common.security.valid.innotation;



import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import org.JWCB.common.security.valid.validator.AllowedValuesValidator;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Retention(value = RetentionPolicy.RUNTIME)
@Constraint(validatedBy = AllowedValuesValidator.class)
public @interface AllowedValues {
    String[] value(); // 允许的值数组

    boolean canNull(); // 允许为空?
    String message() default "参数必须为：{value} 之一"; // 默认消息，{value}将被替换为实际值
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
}